/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import Arbori.ArboreFunctional;
import Arbori.Nod;
import Functii.Constanta;
import Functii.Necunoscuta;
import Interfata.CreazaCopac;
import Operatori.Plus;
import Operatori.Produs;
import Parser.Parser;
import Parser.PostFixForm;
import java.util.ArrayList;
import junit.framework.TestCase;

/**
 *
 * @author AlinT
 */
public class teste extends TestCase {
    
    public teste(String testName) {
        super(testName);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    // TODO add test methods here. The name must begin with 'test'. For example:
    // public void testHello() {}

    public void testParser(){
        String functie = "x+1";
        ArrayList<String> rezultat = new ArrayList<String>();
        rezultat.add("x");rezultat.add("1");rezultat.add("+");
        Parser parser = new PostFixForm();
        ArrayList<String> pozitii = parser.polishForm(parser.createPoz(functie));
        assertEquals(rezultat, pozitii);
    }

    public void testCreazaArbore(){
        String functie = "x*3+7";
        Nod plus = new Plus();
        Nod sapte = new Constanta(7);
        Nod trei = new Constanta(3);
        Nod produs = new Produs();
        Nod x = new Necunoscuta();
        plus.setfDrept(sapte); plus.setfStang(produs);
        produs.setfDrept(trei); produs.setfStang(x);
        ArboreFunctional arb = new ArboreFunctional(plus);
        CreazaCopac a = new CreazaCopac(functie);
        assertEquals(arb.getRadacina().getfDrept().getX(), a.getArbore().getRadacina().getfDrept().getX());
    }
}
